package com.toyota.toyotaownerspoc.util;


import android.content.res.Resources;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.util.Log;
import android.widget.ImageView;

public class BitmapWorkerTask implements Runnable

{
	
	private int requiredHeight = 0; 
	private int requiredWidth = 0; 
	private String imageFilePath = null;
	private volatile boolean flag = false; 
	private Bitmap bitmap = null; 

public BitmapWorkerTask(String imageFilePath, int requiredWidth, int requiredHeight) {
		super();
		this.requiredHeight = requiredHeight;
		this.requiredWidth = requiredWidth;
		this.imageFilePath = imageFilePath;
	}


// Decode image in background.   
@SuppressWarnings("finally")
public void run() 
 {       
    
	Bitmap bitmap = null; 

	synchronized(this)
	{
	try
	{
	bitmap= ImageUtility.decodeSampledBitmapFromResource(this.imageFilePath ,this.requiredWidth ,this.requiredHeight);
	setBitmap(bitmap);
	}
	catch (Exception exc)
	{
		exc.printStackTrace();
	}
	finally
	{
    Log.d("BitmapWorkerTask, run(), newBitmapWorkerTask.isFlag():", String.valueOf(isFlag()));
	setFlag(true);
	notifyAll();
	}
	}
	}
	

public Bitmap getBitmap() {
	return bitmap;
}

public void setBitmap(Bitmap bitmap) {
	this.bitmap = bitmap;
}

public boolean isFlag() {
	return this.flag;
}

public void setFlag(boolean flag) {
	this.flag = flag;
}



public void setRequiredHeight(int requiredHeight) {
	this.requiredHeight = requiredHeight;
}



public void setRequiredWidth(int requiredWidth) {
	this.requiredWidth = requiredWidth;
}



public void setImageFilePath(String imageFilePath) {
	this.imageFilePath = imageFilePath;
}




}
